﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utility1;

namespace Thv.admin.Pages
{
    public partial class Thanhvien : System.Web.UI.UserControl
    {
        private string tempath = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            tempath = WebUtils.SystemUrl();
            if (!IsPostBack)
                Bindata();
        }
        void Bindata()
        {
            DataClasses1DataContext dx = new DataClasses1DataContext();
            var list = from k in dx.UserDBs
                       where k.flag == 1 && k.kichhoat == true
                       select k;
            grvTV.DataSource = list;
            grvTV.DataBind();
        }

        protected void grvTV_AfterPerformCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewAfterPerformCallbackEventArgs e)
        {
            Bindata();
        }

        protected void linkXem_Click(object sender, EventArgs e)
        {
            int id = (int)grvTV.GetRowValues(grvTV.FocusedRowIndex, "ID");
            string name = (string)grvTV.GetRowValues(grvTV.FocusedRowIndex, "UserName");
            //DataClasses1DataContext dx = new DataClasses1DataContext();
            //UserDB u = new UserDB();
            //u = dx.UserDBs.Single(p => p.ID == id);
            //u.kichhoat = true;
            Session["Uss"] = name;
            Session["IdUse"] = id;
            string link = tempath +"/admin/index.aspx?page=So-do&&name=" + name;
            Response.Redirect(link);
          
        }
    }
}